package com.neepu.controller;


import com.neepu.pojo.Investigation;
import com.neepu.pojo.User;
import com.neepu.service.EvaluationResultService;
import com.neepu.service.InvestigationService;
import com.neepu.util.annotation.ArchivesLog;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

@Controller
public class EvaluationResultController {

    @Autowired
    private EvaluationResultService evaluationResultService;

    @Autowired
    private  InvestigationService investigationService;

    @ArchivesLog(operteContent = "查看评价结果")
    @RequestMapping(value = "/evaluate/result")
    public String evaluationResult(Integer userType, Model model){

        //根据用户的类型去判断 是管理员还是 教师
        if (userType==1){ // 教师   教师的结果页面
            return "evaluationresult/teacher_result";
        }else {  // 管理员   查看所有教师的结果
            // 查询所有教师
            List<User> list = evaluationResultService.countTeacher();
            model.addAttribute("teacher_list",list);
            return "evaluationresult/allresult";
        }
    }

    /**
     * 获取男女比例饼状图数据
     */

    @RequestMapping(value="/echartsData")
    @ResponseBody
    public List<Map<String, Object>> initChart(String id){
        return evaluationResultService.pieData(id);
    }


    /**
     * 获取评价指标数据
     */
    @RequestMapping(value="/echartsData1")
    @ResponseBody
    public List<Map<String, Object>> initChart1(String id){
        return evaluationResultService.pieData2(id);
    }

    /**
     * 评价结果
     */
    @RequestMapping(value = "/investigation")
    public String investigation(Model model,Integer id){
        // 通过培养方案id查找培养方案的评价结果
        List<Investigation> list =  investigationService.findAllInvestigation();
        model.addAttribute("list",list);
        return "evaluationresult/allresult1";
    }
}
